var b2Vec2 = Box2D.Common.Math.b2Vec2
  , b2AABB = Box2D.Collision.b2AABB
  ,	b2BodyDef = Box2D.Dynamics.b2BodyDef
  ,	b2Body = Box2D.Dynamics.b2Body
  ,	b2FixtureDef = Box2D.Dynamics.b2FixtureDef
  ,	b2Fixture = Box2D.Dynamics.b2Fixture
  ,	b2World = Box2D.Dynamics.b2World
  ,	b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape
  ,	b2CircleShape = Box2D.Collision.Shapes.b2CircleShape
  ,	b2DebugDraw = Box2D.Dynamics.b2DebugDraw
  , b2BuoyancyController = Box2D.Dynamics.Controllers.b2BuoyancyController
  , b2MouseJointDef =  Box2D.Dynamics.Joints.b2MouseJointDef
  , b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef
  ,      b2RayCastInput = Box2D.Collision.b2RayCastInput
  ,      b2RayCastOutput = Box2D.Collision.b2RayCastOutput
  ;

// Box2d world
var world = null;

// Buoyancy controller
var bC = null;

// Pixel to Meter ration
var PTM_RATIO = 30.0;

//Position on mouse in b2d_world
var mouse_pos = {x: 0, y:0};

// Flag to check if the mouse is pressed
var mouse_pressed = false;

// Mouse joint for when moving the chain
var mouse_joint = false;

//Reference to the ceiling body
var ceiling;



var start_speed = 1;


var currentRayAngle = 0;
var input = new b2RayCastInput();
var output = new b2RayCastOutput();
var b = new b2BodyDef();
var f = new b2FixtureDef();
var closestFraction = 1;
var intersectionNormal = new b2Vec2(0,0);
var intersectionPoint = new b2Vec2();
rayLength = 25; //long enough to hit the walls
var p1 = new b2Vec2( 1, 1 ); //center of scene
var p2 = new b2Vec2();
var normalEnd = new b2Vec2();




var currentRayAngle2 = 0;
var input2 = new b2RayCastInput();
var output2 = new b2RayCastOutput();
var b2 = new b2BodyDef();
var f2 = new b2FixtureDef();
var closestFraction2 = 1;
var intersectionNormal2 = new b2Vec2(0,0);
var intersectionPoint2 = new b2Vec2();
rayLength2 = 25; //long enough to hit the walls
var p12 = new b2Vec2( 1, 1 ); //center of scene
var p22 = new b2Vec2();
var normalEnd2 = new b2Vec2();

var ball;
var magnitude=5;

var context = document.getElementById("canvas").getContext("2d");

var abdomenBody = new Array();
var abdomenJoint = new Array();

var armBodyLeft = new Array();
var armJointLeft = new Array();

var armBodyRight = new Array();
var armJointRight = new Array();

var leftShoulderJoint;
var rightShoulderJoint;


function createLeftArmBodys(){
	
	var canvas = document.getElementById('canvas');
	canvas_width_m = canvas.offsetWidth / PTM_RATIO;
	canvas_height_m = canvas.offsetHeight / PTM_RATIO;
	var chain_length = 0.5;
	var last_link = null;
	var last_anchor_point = new b2Vec2(0,0);
	var joint_def = new b2RevoluteJointDef();
	joint_def.upperAngle = 0.2;
	joint_def.lowerAngle = -0.2;
	joint_def.enableLimit = true;
	joint_def.maxMotorTorque = 300.0; 
	joint_def.motorSpeed = start_speed;
	joint_def.enableMotor = false;
	
	var width = 0.25;

	// The chain will have 6 links
	for(var i = 0; i <= 3; i++){
		var link = createBox(width, 
							 chain_length, 
							 canvas_width_m/2, 
							 chain_length + i*chain_length*2, 
							 b2Body.b2_dynamicBody);
		
		armBodyLeft[i] = link;
		bC.AddBody(link);

		if (last_link != null){
			joint_def.bodyA = last_link;
			joint_def.bodyB = link;

			joint_def.localAnchorA = last_anchor_point;
			joint_def.localAnchorB = new b2Vec2(0, -.75*chain_length);

			last_anchor_point = new b2Vec2(0, .75*chain_length);

			armJointLeft[i] = world.CreateJoint(joint_def);
			
		
			
		}
		
		last_link = link;
	}

	
}

function createRightArmBodys(){
	
	var canvas = document.getElementById('canvas');
	canvas_width_m = canvas.offsetWidth / PTM_RATIO;
	canvas_height_m = canvas.offsetHeight / PTM_RATIO;
	var chain_length = 0.5;
	var last_link = null;
	var last_anchor_point = new b2Vec2(0,0);
	var joint_def = new b2RevoluteJointDef();
	joint_def.upperAngle = 0.2;
	joint_def.lowerAngle = -0.2;
	joint_def.enableLimit = true;
	joint_def.maxMotorTorque = 300.0; 
	joint_def.motorSpeed = start_speed;
	joint_def.enableMotor = false;
	
	var width = 0.25;

	// The chain will have 6 links
	for(var i = 0; i <= 3; i++){
		var link = createBox(width, 
							 chain_length, 
							 canvas_width_m/2, 
							 chain_length + i*chain_length*2, 
							 b2Body.b2_dynamicBody);
		
		armBodyRight[i] = link;
		bC.AddBody(link);

		if (last_link != null){
			joint_def.bodyA = last_link;
			joint_def.bodyB = link;

			joint_def.localAnchorA = last_anchor_point;
			joint_def.localAnchorB = new b2Vec2(0, -.75*chain_length);

			last_anchor_point = new b2Vec2(0, .75*chain_length);

			armJointRight[i] = world.CreateJoint(joint_def);
			
		
			
		}
		
		last_link = link;
	}

	
}

function createAbdomenBodys(){
	
	var canvas = document.getElementById('canvas');
	canvas_width_m = canvas.offsetWidth  / PTM_RATIO;
	canvas_height_m = canvas.offsetHeight / PTM_RATIO;
	var chain_length = 0.5;
	var last_link = null;
	var last_anchor_point = new b2Vec2(0,0);
	var joint_def = new b2RevoluteJointDef();
	joint_def.upperAngle = 0.1;
	joint_def.lowerAngle = -0.1;
	joint_def.enableLimit = true;
	joint_def.maxMotorTorque = 300.0; 
	joint_def.motorSpeed = start_speed;
	joint_def.enableMotor = false;
	
	var width = 0.25;

	// The chain will have 6 links
	for(var i = 0; i <= 10; i++){
		var link = createBox(width, 
							 chain_length, 
							 chain_length + i*chain_length*2 + 10, 
							 chain_length + i*chain_length*2 + 20,
							 b2Body.b2_dynamicBody);
		
		abdomenBody[i] = link;
		bC.AddBody(link);

		if (last_link != null){
			joint_def.bodyA = last_link;
			joint_def.bodyB = link;

			joint_def.localAnchorA = last_anchor_point;
			joint_def.localAnchorB = new b2Vec2(0, -.75*chain_length);

			last_anchor_point = new b2Vec2(0, .75*chain_length);

			abdomenJoint[i] = world.CreateJoint(joint_def);
		
			
		}
		
		last_link = link;
	}

	
}


function getBodyAtMouse(includeStatic){
	var mouse_p = new b2Vec2(mouse_pos.x, mouse_pos.y);
	var sensitivity_offset = 0.001;

	var aabb = new b2AABB();
	aabb.lowerBound.Set(mouse_pos.x - sensitivity_offset, 
						mouse_pos.y - sensitivity_offset);

	aabb.upperBound.Set(mouse_pos.x + sensitivity_offset, 
						mouse_pos.y + sensitivity_offset);

	var body = null;

	// Query the world for overlapping shapes.
	function GetBodyCallback(fixture)
	{
		var shape = fixture.GetShape();

		if (fixture.GetBody().GetType() != b2Body.b2_staticBody || includeStatic)
		{
			var inside = shape.TestPoint(fixture.GetBody().GetTransform(), mouse_p);

			if (inside)
			{
				body = fixture.GetBody();
				return false;
			}
		}

		return true;
	}

	world.QueryAABB(GetBodyCallback, aabb);
	return body;
}

function createBall(radius, x, y, type){
	// Create the fixture definition
	var fixDef = new b2FixtureDef;
	
	fixDef.density = 1.0;	// Set the density
	fixDef.friction = 1.0;	// Set the friction
	fixDef.restitution = 0.5;	// Set the restitution - bounciness
	 
	// Set the shape of the fixture to be a circle
	fixDef.shape = new b2CircleShape(radius);
   
	// Create the body definition
	var bodyDef = new b2BodyDef;
	bodyDef.type = type;
   
	// Set the position of the body
	bodyDef.position.x = x;
	bodyDef.position.y = y;
   
	// Create the body in the box2d world
	var b = world.CreateBody(bodyDef);
	b.CreateFixture(fixDef);
   
	return b;
}

function createBox(w, h, x, y, type){
	// Create the fixture definition
	var fixDef = new b2FixtureDef;
	
	fixDef.density = 1.0;	// Set the density
	fixDef.friction = 1.0;	// Set the friction
	fixDef.restitution = 90.1;	// Set the restitution - bounciness 
	
	fixDef.filter.maskBits=0;
	fixDef.filter.categoryBits =0;
	
	// Define the shape of the fixture
	fixDef.shape = new b2PolygonShape;
	fixDef.shape.SetAsBox(
				   w // input should be half the width
				 , h // input should be half the height
	);
    
    // Create the body definition
	var bodyDef = new b2BodyDef;
	bodyDef.type = type;
	
	// Set the position of the body
	bodyDef.position.x = x;
	bodyDef.position.y = y;
   
	// Create the body in the box2d world
	var b = world.CreateBody(bodyDef);
	b.CreateFixture(fixDef);
   
	return b;
}

function setDebugDraw(w){
	var debugDraw = new b2DebugDraw();
	debugDraw.SetSprite(document.getElementById("canvas").getContext("2d"));
	debugDraw.SetDrawScale(PTM_RATIO); // Set draw scale
	//debugDraw.SetAlpha(1);
	debugDraw.SetFillAlpha(0.3);
	debugDraw.SetLineThickness(1.0);
	debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit);
	
	// set debug draw to the world
	w.SetDebugDraw(debugDraw); 
}

function getMousePos(src_elem, event){
	var totalOffsetX = 0;
	var totalOffsetY = 0;
	var x_pos = 0;
	var y_pos = 0;
	var currElement = src_elem;
	//console.log(src_elem);

	// IE, Chrome
	if(event.offsetX !== undefined && event.offsetY !== undefined) {
		x_pos = event.offsetX;
		y_pos = event.offsetY;
	}

	// Firefox

	else {
		do{
			totalOffsetX += currElement.offsetLeft - currElement.scrollLeft;
			totalOffsetY += currElement.offsetTop - currElement.scrollTop;
		}
		while(currElement = currElement.offsetParent)

		x_pos = event.pageX - totalOffsetX - document.body.scrollLeft; 
		y_pos = event.pageY - totalOffsetY - document.body.scrollTop;
	}
	
	return {x: x_pos / PTM_RATIO, y: y_pos / PTM_RATIO};
}

function init() {
	//
	// Create the box2d world
	//
	world = new b2World(
						new b2Vec2(0, 0),   //gravity
						true                 //allow sleep
					   );
					
    
    // Get the dimensions of the canvas object on the page
	var canvas = document.getElementById('canvas');
	
	// Convert using the pixel to meter ratio to get the correct
	// box2d values
	canvas_width_m = canvas.offsetWidth / PTM_RATIO;
	canvas_height_m = canvas.offsetHeight / PTM_RATIO;
	
	ceiling = createBox(canvas_width_m/2, 0.5, canvas_width_m/2, 0.5, b2Body.b2_staticBody);  
	
	//
	// Create a buoyancy controller
	//
	bC = new b2BuoyancyController();
	world.AddController(bC);
	
	// set the surface normal
	bC.normal.Set(0,-1);
	
	// set the offset from the top of the canvas
	bC.offset = -1 * ( canvas_height_m / 8 );
	
	// set the water density
	bC.density = 5;
	
	// set linear drag
	bC.linearDrag = 1;
	bC.AngularDrag = 0;
   
	
	
	var x = 10;
	var y = 5;
	var height = 0.5;
	var width = 0.25;
	
	createAbdomenBodys();
	
	
	
	ball = createBall(width,30,20, b2Body.b2_dynamicBody);
	bC.AddBody(ball);
		
	
	var jointDef = new b2RevoluteJointDef();
	var DEGTORAD = Math.PI/180;

	jointDef.maxMotorTorque = 300.0; 
	height = 0.25;
	width = 0.5;
	
	//shoulders
	jointDef.enableMotor = true;
	jointDef.motorSpeed = start_speed;
	jointDef.enableLimit = true;
	jointDef.localAnchorA = new b2Vec2(0, 0);
	jointDef.localAnchorB = new b2Vec2(0, 0);
	
	createLeftArmBodys();
	jointDef.upperAngle = 330*DEGTORAD;
	jointDef.lowerAngle = 210*DEGTORAD;

	jointDef.bodyA = abdomenBody[abdomenBody.length-3];
	jointDef.bodyB = armBodyLeft[0];
	leftShoulderJoint =  world.CreateJoint(jointDef);
	
	createRightArmBodys();
	
	jointDef.upperAngle = 150*DEGTORAD;
	jointDef.lowerAngle = 30*DEGTORAD;
	jointDef.bodyA = abdomenBody[abdomenBody.length-3];
	jointDef.bodyB = armBodyRight[0];
	rightShoulderJoint =  world.CreateJoint(jointDef);
	
	
	
	
	
	
	
	
	//*/
	
	
    //
	// Configure debug draw
	//
	setDebugDraw(world);
	
	 
    
    
	 	
	
	canvas.addEventListener('mousemove', function(e) {
		   mouse_pos = getMousePos(this, e);
		   b2d_pos = new b2Vec2(mouse_pos.x, mouse_pos.y);

		   if(mouse_pressed && !mouse_joint)
		   {
			   var body = getBodyAtMouse();

			   if(body)
			   {
					// create the mouse joint
					var def = new b2MouseJointDef();

					// joints need two bodies, in the case of
					// mouse joints bodyA can be *any* body in
					// the world. I would use some static body.
					// It is not allowed to be null or undefined.
					def.bodyA = ceiling;
					def.bodyB = body;
					def.target = b2d_pos;

					// disable collision detection between
					// connected bodies
					def.collideConnected = false;

					// set the max for that can be exerted 
					// on the body based on the bodies mass
					def.maxForce = 1000 * body.GetMass();

					// Prevent oscillating
					def.dampingRatio = 1;

					// create the mouse joint in the world
					mouse_joint = world.CreateJoint(def);

					// Wake up a body in case it is sleeping
					//body.SetAwake(false);
			   }
		   }

		   if(mouse_joint)
		   {
			   mouse_joint.SetTarget(b2d_pos);
		   }
	}, false);

	canvas.addEventListener('mousedown', function(e){
	   mouse_pressed = true;
	}, false);

	canvas.addEventListener('mouseup', function(e){
		   mouse_pressed = false;

		   if(mouse_joint){
			   world.DestroyJoint(mouse_joint);
			   mouse_joint = false;
		   }
	}, false);
	
	//
	// Create an interval that calls the update function 60 times a second
	//
	window.setInterval(update, 1000 / 60);
};

function ray()  {
	
    //in Step() function
	var DEGTORAD = Math.PI/180;
	var armBody = armBodyLeft[3];
    currentRayAngle =270 * DEGTORAD +  armBody.GetAngle()*-1 ;
    
    p1 = armBody.GetWorldCenter();
    //calculate points of ray
    p2.x = p1.x + rayLength * Math.sin(currentRayAngle);
    p2.y = p1.y + rayLength * Math.cos(currentRayAngle);

    input.p1 = p1;
    input.p2 = p2;
    input.maxFraction = 1;
    closestFraction = 1;

   // var b = new b2BodyDef();
    var f = new b2FixtureDef();
    var b = ball;
        for(f = b.GetFixtureList(); f; f = f.GetNext()) {
            if(!f.RayCast(output, input))
                continue;
            else if(output.fraction < closestFraction)  {
                closestFraction = output.fraction;
                            intersectionNormal = output.normal;
            }
        }

    if (closestFraction != 1){
    	//var force = new b2Vec2(5 ,0);
    	
    
    	var force = new b2Vec2( (Math.cos(armBody.GetAngle())* -1)  , (Math.sin(armBody.GetAngle()* -1 )));
    	leftShoulderJoint.SetMotorSpeed( -1);
    	console.log('set left shoulder to ' + leftShoulderJoint.GetMotorSpeed());
    	armBody.ApplyForce( force  ,  armBody.GetPosition());
  
    	
    	
//    	var canvas = document.getElementById('canvas');
//    	var ctx = canvas.getContext('2d');
//    	ctx.save();
//    	ctx.fillStyle = "yellow";
//    	ctx.beginPath();
//    	
//    	ctx.rect((force.x+ armBody.GetWorldCenter().x)*PTM_RATIO ,(force.y + armBody.GetWorldCenter().y)*PTM_RATIO,
//    			 5,5);
//    	ctx.fill();
//    	ctx.restore();
    }
    
    intersectionPoint.x = p1.x + closestFraction * (p2.x - p1.x);
    intersectionPoint.y = p1.y + closestFraction * (p2.y - p1.y);

    normalEnd.x = intersectionPoint.x + intersectionNormal.x;
    normalEnd.y = intersectionPoint.y + intersectionNormal.y;

    context.strokeStyle = "rgb(255, 255, 255)";

    context.beginPath(); // Start the path
    context.moveTo(p1.x*30,p1.y*30); // Set the path origin
    context.lineTo(intersectionPoint.x*30, intersectionPoint.y*30); // Set the path destination
    context.closePath(); // Close the path
    context.stroke();

}
function ray2()  {
	
    //in Step() function
	var DEGTORAD = Math.PI/180;
	var armBody = armBodyRight[3];
    currentRayAngle2 = 90 * DEGTORAD + armBody.GetAngle()*-1 ;
    
    p12 = armBody.GetWorldCenter();
    //calculate points of ray
    p22.x = p12.x + rayLength2 * Math.sin(currentRayAngle2);
    p22.y = p12.y + rayLength2 * Math.cos(currentRayAngle2);

    input.p1 = p12;
    input.p2 = p22;
    input.maxFraction = 1;
    closestFraction2 = 1;

    //var b = new b2BodyDef();
    var f = new b2FixtureDef();
    var b = ball;
        for(f = b.GetFixtureList(); f; f = f.GetNext()) {
            if(!f.RayCast(output, input))
                continue;
            else if(output.fraction < closestFraction2)  {
            	closestFraction2 = output.fraction;
                            intersectionNormal = output.normal;
            }
        }

    if (closestFraction2 != 1){
    	//var force = new b2Vec2(5 ,0);
    	
    	var force2 = new b2Vec2( (Math.cos(armBody.GetAngle())* 1) , (Math.sin(armBody.GetAngle()* 1 )));
    	rightShoulderJoint.SetMotorSpeed(1);
    	armBody.ApplyForce( force2  ,  armBody.GetPosition());
    	
    	
    	
//    	var canvas = document.getElementById('canvas');
//    	var ctx = canvas.getContext('2d');
//    	ctx.save();
//    	ctx.fillStyle = "blue";
//    	ctx.beginPath();
//    	
//    	ctx.rect((force2.x+ armBody.GetWorldCenter().x)*PTM_RATIO ,(force2.y + armBody.GetWorldCenter().y)*PTM_RATIO,
//    			 5,5);
//    	ctx.fill();
//    	ctx.restore();
    	
    	
    }
    
    intersectionPoint2.x = p12.x + closestFraction2 * (p22.x - p12.x);
    intersectionPoint2.y = p12.y + closestFraction2 * (p22.y - p12.y);

    normalEnd.x = intersectionPoint.x + intersectionNormal.x;
    normalEnd.y = intersectionPoint.y + intersectionNormal.y;

    context.strokeStyle = "rgb(255, 255, 255)";

    context.beginPath(); // Start the path
    context.moveTo(p12.x*30,p12.y*30); // Set the path origin
    context.lineTo(intersectionPoint2.x*30, intersectionPoint2.y*30); // Set the path destination
    context.closePath(); // Close the path
    context.stroke();

}



function update() {
    // Update the world simulation
	world.Step(
		  1 / 60,   //frame-rate
		  10,       //velocity iterations
		  10        //position iterations
	);
    
    // Update the buoyancy controller
	bC.Step(1/60);
  	
  	// Draw debug data on the canvas
	world.DrawDebugData();
	
	world.ClearForces();
	
	 //world.SetContactListener(listener);
     ray();
     ray2();
	
	
	// Draw water level
	var canvas = document.getElementById('canvas');
	var ctx = canvas.getContext('2d');
	ctx.save();
	ctx.fillStyle = "rgba(180,201,255, 0.5)";
	ctx.beginPath();
	ctx.rect(0,
			 canvas.offsetHeight/8,
			 canvas.offsetWidth,
			 canvas.offsetHeight);
	ctx.fill();
	ctx.restore();
	
	var speed;
	var angle; 
	
	//arms
	
	for(var i = 0; i < armJointLeft.length; i++){
		var arm_joint = armJointLeft[i];
		
		if (arm_joint){
			speed = arm_joint.GetMotorSpeed();
			angle = arm_joint.GetJointAngle();
			if((speed < 0.0  && angle <= arm_joint.GetLowerLimit()) || 
			   (speed > 0.0  && angle >= arm_joint.GetUpperLimit())
			){
				arm_joint.SetMotorSpeed(speed * -1.0);
			}
		}
	
	
	}
	
	for(var i = 0; i < armJointRight.length; i++){
		var arm_joint = armJointRight[i];
		
		if (arm_joint){
			speed = arm_joint.GetMotorSpeed();
			angle = arm_joint.GetJointAngle();
			if((speed < 0.0  && angle <= arm_joint.GetLowerLimit()) || 
			   (speed > 0.0  && angle >= arm_joint.GetUpperLimit())
			){
				arm_joint.SetMotorSpeed(speed * -1.0);
			}
		}
	
	}
	
	
	if (leftShoulderJoint){
		speed = leftShoulderJoint.GetMotorSpeed();
		angle = leftShoulderJoint.GetJointAngle();
		if((speed < 0.0  && angle <= leftShoulderJoint.GetLowerLimit()) || 
		   (speed > 0.0  && angle >= leftShoulderJoint.GetUpperLimit())
		){
			leftShoulderJoint.SetMotorSpeed(speed * -1.0);
		}
		
		if (speed < 0){
			var armBody = armBodyLeft[3];
			var bodyspeed = armBody.GetLinearVelocity().Normalize();
			var force = new b2Vec2( (Math.cos(armBody.GetAngle())* -1) * bodyspeed * magnitude , (Math.sin(armBody.GetAngle()* -1 ))* bodyspeed * magnitude);
	    	armBody.ApplyForce( force  ,  armBody.GetPosition());
			
		}
		if (speed < 0){
			var armBody = armBodyLeft[2];
			var bodyspeed = armBody.GetLinearVelocity().Normalize();
			var force = new b2Vec2( (Math.cos(armBody.GetAngle())* -1) * bodyspeed * magnitude , (Math.sin(armBody.GetAngle()* -1 ))* bodyspeed * magnitude);
	    	armBody.ApplyForce( force  ,  armBody.GetPosition());
			
		}
	}
	
	
	
	

	if (rightShoulderJoint){
		speed = rightShoulderJoint.GetMotorSpeed();
		angle = rightShoulderJoint.GetJointAngle();
		if((speed < 0.0  && angle <= rightShoulderJoint.GetLowerLimit()) || 
		   (speed > 0.0  && angle >= rightShoulderJoint.GetUpperLimit())
		){
			rightShoulderJoint.SetMotorSpeed(speed * -1.0);
		}
		
		if (speed > 0){
			var armBody = armBodyRight[3];
			var bodyspeed = armBody.GetLinearVelocity().Normalize();
			var force2 = new b2Vec2( (Math.cos(armBody.GetAngle())* 1) * bodyspeed * magnitude, (Math.sin(armBody.GetAngle()* 1 ))* bodyspeed * magnitude);
	    	armBody.ApplyForce( force2  ,  armBody.GetPosition());
		}
		if (speed > 0){
			var armBody = armBodyRight[2];
			var bodyspeed = armBody.GetLinearVelocity().Normalize();
			var force2 = new b2Vec2( (Math.cos(armBody.GetAngle())* 1) * bodyspeed * magnitude, (Math.sin(armBody.GetAngle()* 1 ))* bodyspeed * magnitude);
	    	armBody.ApplyForce( force2  ,  armBody.GetPosition());
		}
		
		
	}



	
	
	
	
	
	
	
};